import numpy as np

import sys

sys.path.append("/home/konghaomin/TrackEval/scripts")
import run_mot_challenge_func

input_result = r"/home/konghaomin/MOTR/exps/e2e_motr_r50_dance_maritime_track/tracker"

res_eval = run_mot_challenge_func.main(
    SPLIT_TO_EVAL="val",
    METRICS=["HOTA", "CLEAR", "Identity"],
    GT_FOLDER="/home/konghaomin/Datasets/MaritimeTrack_20250322_D/DanceTrack/val",
    SEQMAP_FILE="/home/konghaomin/Datasets/MaritimeTrack_20250322_D/DanceTrack/val_seqmap.txt",
    SKIP_SPLIT_FOL=True,
    TRACKERS_TO_EVAL=[""],
    TRACKER_SUB_FOLDER="",
    USE_PARALLEL=True,
    NUM_PARALLEL_CORES=8,
    PLOT_CURVES=False,
    TRACKERS_FOLDER=input_result,
)

# HOTA
hota = float(
    np.mean(
        res_eval[0]["MotChallenge2DBox"][""]["COMBINED_SEQ"]["pedestrian"]["HOTA"][
            "HOTA"
        ]
    )
)

# DetA AssA MOTA

deta = float(
    np.mean(
        res_eval[0]["MotChallenge2DBox"][""]["COMBINED_SEQ"]["pedestrian"]["HOTA"][
            "DetA"
        ]
    )
)

assa = float(
    np.mean(
        res_eval[0]["MotChallenge2DBox"][""]["COMBINED_SEQ"]["pedestrian"]["HOTA"][
            "AssA"
        ]
    )
)

mota = res_eval[0]["MotChallenge2DBox"][""]["COMBINED_SEQ"]["pedestrian"]["CLEAR"][
    "MOTA"
]

idf1 = res_eval[0]["MotChallenge2DBox"][""]["COMBINED_SEQ"]["pedestrian"]["Identity"][
    "IDF1"
]


def convert_result_to_str(result):
    return str(round(result * 100, 3))


hota, deta, assa, mota, idf1 = (
    convert_result_to_str(hota),
    convert_result_to_str(deta),
    convert_result_to_str(assa),
    convert_result_to_str(mota),
    convert_result_to_str(idf1),
)


print("\n" * 3)
print(f"HOTA DetA AssA MOTA IDF1")
print(f"{hota} {deta} {assa} {mota} {idf1}")


# print(convert_result_to_str(result))
